﻿package com.mui.core
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.utils.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.utils.*;

    public class GlobalClass extends Object
    {
        public static var libaray:Library = new Library("global");
        private static var _bitmapdataMap:Dictionary = new Dictionary();
        private static var _colorMap:Dictionary = new Dictionary();

        public function GlobalClass()
        {
            return;
        }// end function

        public static function hasRes(param1:String) : Boolean
        {
            return libaray.hasDefinition(param1);
        }// end function

        public static function getInstance(param1:String)
        {
            var _loc_2:* = libaray.getDefinition(param1);
            return new _loc_2;
        }// end function

        public static function getClass(param1:String) : Class
        {
            return libaray.getDefinition(param1);
        }// end function

        public static function getBitmapData(param1:String) : BitmapData
        {
            if (!(param1 in _bitmapdataMap))
            {
                _bitmapdataMap[param1] = getBitmapdataImpl(param1);
            }
            return _bitmapdataMap[param1];
        }// end function

        public static function disposeBitmapData(param1:String) : Boolean
        {
            var _loc_2:BitmapData = null;
            if (_bitmapdataMap[param1])
            {
                _loc_2 = _bitmapdataMap[param1];
                _loc_2.dispose();
                delete _bitmapdataMap[param1];
                return true;
            }
            return false;
        }// end function

        public static function getBitmapDataByColor(param1:int) : BitmapData
        {
            if (!(param1 in _colorMap))
            {
                _colorMap[param1] = new BitmapData(10, 10, true, param1);
            }
            return _colorMap[param1];
        }// end function

        public static function addBitmapData(param1:String, param2:BitmapData) : void
        {
            if (!(param1 in _bitmapdataMap))
            {
                _bitmapdataMap[param1] = param2;
            }
            return;
        }// end function

        public static function getBitmap(param1:String) : GBitmap
        {
            var _loc_3:GBitmap = null;
            var _loc_2:* = getBitmapData(param1);
            if (_loc_2 != null)
            {
                _loc_3 = UICompomentPool.getUICompoment(GBitmap) as GBitmap;
                _loc_3.bitmapData = _loc_2;
                return _loc_3;
            }
            return null;
        }// end function

        public static function getScaleBitmap(param1:String, param2:Rectangle = null) : ScaleBitmap
        {
            var _loc_4:ScaleBitmap = null;
            var _loc_3:* = getBitmapData(param1);
            if (_loc_3 != null)
            {
                _loc_4 = UICompomentPool.getUICompoment(ScaleBitmap) as ScaleBitmap;
                _loc_4.bitmapData = _loc_3.clone();
                _loc_4.createDisposeChildren();
                _loc_4.scale9Grid = param2;
                return _loc_4;
            }
            return null;
        }// end function

        private static function getBitmapdataImpl(param1:String) : BitmapData
        {
            var _loc_2:* = getClass(param1);
            if (_loc_2 != null)
            {
                return new _loc_2(0, 0) as BitmapData;
            }
            return null;
        }// end function

    }
}
